package com.addressbook.tests;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;

import org.testng.annotations.Test;

import com.addressbook.fw.GroupObject;
import com.addressbook.fw.Groups;

public class GroupModificationTests extends TestBase{
	@Test
	public void testSomeGroupCanBeModifed() throws Exception {
		Groups oldGroups = app.getGroupHelper().getGroups();
		GroupObject oldGroup = oldGroups.getSomeGroup();
		GroupObject newGroup = new GroupObject(oldGroup);
		newGroup.setName("MODIFIED");
		app.getGroupHelper().modifyGroup(oldGroup, newGroup);
		Groups newGroups = app.getGroupHelper().getGroups();
		assertThat(newGroups, equalTo(oldGroups.without(oldGroup).withAdded(newGroup)));
	}
}
